package com.cskaoyan.servlet;

import com.cskaoyan.bean.HistoryParameter;
import com.cskaoyan.bean.PageData;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.common.CommonServlet;
import com.cskaoyan.model.MarketSearchHistory;
import com.cskaoyan.service.HistoryService;
import com.cskaoyan.service.impl.HistoryServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/admin/history/*")
public class AdminHistoryServlet extends CommonServlet {
    HistoryService historyService = new HistoryServiceImpl();

    public BaseRespVo list(HttpServletRequest request, HttpServletResponse response) throws InvocationTargetException, IllegalAccessException {
        Map<String, String[]> parameterMap = request.getParameterMap();
        HistoryParameter historyParameter = new HistoryParameter();
        BeanUtils.copyProperties(historyParameter, parameterMap);

        PageData pageData = historyService.list(historyParameter);
        return BaseRespVo.ok(pageData);
    }
}
